class student:
    def study(self):
        print()
        print("好好学习，天天向上。")

class it(student):
    def code(self):
        print("编程")

class yuan(student):
    def jy(self):
        print("金融交易")



y=student()
y.study()

a=it()
a.study()
a.code()

b=yuan()
b.study()
b.jy()

class person:
    def __init__(self,name,age):
        print("====初始化开始啦========")
        self.age = age
        self.name = name
        print("=====初始化结束啦==========")
    def show(self):
        print("我的名字是：",self.name)
        print("我的年龄是：",self.age)

yq=person("杨青",18)
yq.show()



class student:
    def __init__(self,name,weight):
        self.name = name
        self.weight = weight

    def study(self):
        print("%s 好好学习"%self.name)

yq=student("杨青",80)
print(yq.name, yq.weight)
yq.study()

# 10.5 继承
# 构造一个基类“学生”，包含“学习”方法。
# 构造继承类“计算机专业学生”，包含方法“编程”。
# 构造继承类“金融专业学生”，包含方法“金融交易”。
# 构造不同类的对象，对各自方法进行调用。
print("10.5 继承")

class student:
    def study(self):
        print("好好学习，天天向上。")

class jisuanji(student):
    def code(self):
        print("编程")

class jinrong(student):
    def jy(self):
        print("金融交易")

student=student()
student.study()

jisuanji=jisuanji()
jisuanji.study()
jisuanji.code()

jinrong=jinrong()
jinrong.study()
jinrong.jy()

# 10.3 封装
class guaishou:
    def __init__(self,name,weight,height):  
        #必须包含self参数，初始化
        print("Hello,准备工作")
        self.name = name
        self.weight = weight
        self.height = height
        print("Hello 初始化结束")     
        
    def show(self):
        print("Hello ，我来了：")
        print("我的名字是：",self.name)
        print("我的体重是：",self.weight)
        print("我的身高是：",self.height)

userid=guaishou("小白",80,180)
userid.show()

# 10.6 多态
class student:  #父类
    def study(self):
        print("好好学习，天天向上。")
class it(student):  #子类
    def study(self):
        print("编程")
class jr(student):  #子类
    def study(self):   
        print("金融")

def startStudy(student):
    print("----准备学习---------")
    student.study()
    print("-----学习结束------")

yq=student()
startStudy(yq)
a=it()
startStudy(a)
b=jr()
startStudy(b)

# 10.4 访问控制
class status:
    def __init__(self,name,weight,height):  
        #必须包含self参数，初始化
        print("Hello,准备工作")
        self.__name = name
        self.__weight = weight
        self.__height = height
        print("Hello 初始化结束")    
        
    def show(self):
        print("Hello ，我来了：")
        print("我的名字是：",self.__name)
        print("我的身高是：",self.__weight)
        print("我的体重是：",self.__height)
    def getName(self):
        return self.__name
    def setName(self,x):
        self.__name=x
    def getWeight(self):
        return self.__weight
    def setWeight(self,x):
        self.__weight=x
    def getHeight(self):    
        return self.__height
    def setHeight(self,x):
        self.__height=x

yq=status("杨青",80,180)
yq.show() 

yq.setHeight(190)
yq.setWeight(90)
yq.show()